﻿<Page
    x:Class="Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Views.Search"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewModels ="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.ViewModels"
    xmlns:converters="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Converters"
    mc:Ignorable="d">
    <Page.Resources>
        <converters:CountToVis x:Key="countToVis"/>
    </Page.Resources>
    <Page.TopAppBar>
        <AppBar>
            <StackPanel Orientation="Horizontal">
                <Button Command="{Binding GoToHome}" Content="Home" Style="{StaticResource AppBarTextButtonStyle}" FontSize="26.667" Margin="40,0,0,0"/>
            </StackPanel>
        </AppBar>
    </Page.TopAppBar>

    <Grid Background="{StaticResource BackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="120"/>
            <RowDefinition Height="20"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140"/>
                <ColumnDefinition  Width="*"/>
            </Grid.ColumnDefinitions>
            <Button Command="{Binding GoBack}" Grid.Column="0" Style="{StaticResource BackButtonStyle}" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center" />
            <TextBlock Grid.Column="1" Style="{StaticResource PageHeaderTextStyle}" Text="Search" Margin="0" FontFamily="{StaticResource TitleFont}" Foreground="{StaticResource TitleBrush}" />
        </Grid>
        <Grid Grid.Row="2" Margin="120,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Text="Categories" Style="{StaticResource TitleTextStyle}"/>
                <TextBlock Grid.Row="2" Visibility="{Binding Categories.Count, Converter={StaticResource countToVis}}" Text="no results found for categories"/>
                <ListView Grid.Row="2" ItemsSource="{Binding Categories}" SelectedItem="{Binding SelectedCategory, Mode=TwoWay}">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" Style="{StaticResource SubheaderTextStyle}">
                                <TextBlock.Foreground>
                                    <SolidColorBrush Color="{StaticResource Title}"/>
                                </TextBlock.Foreground>
                            </TextBlock>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </Grid>
            <Grid Grid.Column="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Text="Projects" Style="{StaticResource TitleTextStyle}"/>
                <TextBlock Grid.Row="2" Visibility="{Binding Projects.Count, Converter={StaticResource countToVis}}" Text="no results found for projects"/>
                <ListView Grid.Row="2" ItemsSource="{Binding Projects}"  SelectedItem="{Binding SelectedProject, Mode=TwoWay}">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Name}" Style="{StaticResource SubheaderTextStyle}">
                                    <TextBlock.Foreground>
                                        <SolidColorBrush Color="{StaticResource Title}"/>
                                    </TextBlock.Foreground>
                                </TextBlock>
                                <TextBlock Text="{Binding Description}" TextWrapping="Wrap" Style="{StaticResource SubtitleTextStyle}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </Grid>
        </Grid>
    </Grid>
</Page>